//
//  MTWalletListViewCell.m
//  MeToo
//
//  Created by 俊松何 on 2018/7/17.
//  Copyright © 2018年 tianxie. All rights reserved.
//

#import "MTWalletListViewCell.h"
#import "UIView+ViewController.h"
#import "MTRecordsViewController.h"

#import "MTTopUpInputNumberView.h"

@interface MTWalletListViewCell ()

@property (weak, nonatomic) IBOutlet UIButton *exchangeButton;
@property (weak, nonatomic) IBOutlet UIButton *withdrawalButton;
@property (weak, nonatomic) IBOutlet UIView *bgView;


@property (weak, nonatomic) IBOutlet UIImageView *coinImageView;
@property (weak, nonatomic) IBOutlet UILabel *coinnameLable;
@property (weak, nonatomic) IBOutlet UILabel *banlanceLable;
@property (weak, nonatomic) IBOutlet UIImageView *bgImageView;

@property (nonatomic,strong) MTTopUpInputNumberView *inputNumberView;


@end


@implementation MTWalletListViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.exchangeButton.borderWidth = 1;
    self.exchangeButton.layer.cornerRadius = 18;
    self.exchangeButton.layer.masksToBounds = YES;
    self.exchangeButton.layer.borderColor = [UIColor whiteColor].CGColor;
    
    self.coinImageView.layer.cornerRadius = 17;
    self.coinImageView.layer.masksToBounds = YES;
    
    self.withdrawalButton.layer.cornerRadius = 18;
    self.layer.masksToBounds = YES;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.bgView.layer.shadowColor = [UIColor blackColor].CGColor;
    self.bgView.layer.shadowOpacity = 0.8f;
    self.bgView.layer.shadowOffset = CGSizeMake(0,0);
    // Initialization code
}

-(void)setCoinModel:(MTCoinModel *)coinModel
{
    _coinModel = coinModel;
    [self.coinImageView sd_setImageWithURL:[NSURL URLWithString:coinModel.coinImage]];
    self.coinnameLable.text = coinModel.symbol;
    self.banlanceLable.text = [NSString stringWithFormat:@"%g",coinModel.balance];
}

-(void)setIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = indexPath.row;
    NSInteger index = row % 3;
    self.bgImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"Card-%ld",index]];
}
- (IBAction)recordClick:(UIButton *)sender {
    MTRecordsViewController *recordsVc = [[MTRecordsViewController alloc] init];
    recordsVc.model = self.coinModel;
    [self.currentViewController.navigationController pushViewController:recordsVc animated:YES];
}

-(MTTopUpInputNumberView *)inputNumberView
{
    if(_inputNumberView == nil)
    {
        _inputNumberView = [MTTopUpInputNumberView topUpInputNumberView];
        _inputNumberView.model = self.coinModel;
        _inputNumberView.presentView = self;
    }
    return _inputNumberView;
}


- (IBAction)topUpClick:(UIButton *)sender {
    [self.inputNumberView show];
}




@end
